// index.js
// const audioCtx = wx.createWebAudioContext();
const api = require("../../api/index");
Page({
  // 放数据
  data: {
    cdList:[
      {"site_name":"五角大楼","site_time":"12:00 - 24:00","site_money":"20/h","site_dz":"幸福路12号"},
      {"site_name":"东安湖","site_time":"12:00 - 24:00","site_money":"25/h","site_dz":"幸福路12号"},
      {"site_name":"阳光城","site_time":"12:00 - 24:00","site_money":"10/h","site_dz":"幸福路12号"}
    ],
    homeTitle:"运动无止境"
  },
  onReady(){
    //页面的调用效果
    api.getMsg().then(data =>
      //this.setData({ exampleData: data })
      console.log(data)
    )
  },
  onShow(){
    wx.request({
      url: 'http://192.168.0.14/config/getValue?system_key=home_title',
      success:(data)=>{
        console.log(data.data.data[0].system_value);
        this.setData({
          homeTitle:data.data.data[0].system_value
        });
      }
    })
  },
  // onReady(){
  //   console.log("页面准备好了")
  //   this.loadAudio('https://m804.music.126.net/20250328230112/056d3d5bf91252f2da27d6141a8eebb5/jdyyaac/obj/w5rDlsOJwrLDjj7CmsOj/58419411752/0486/1793/40b5/256772d40181d03a47e68dbfd53c3a01.m4a?vuutv=Cia3z7czREIm63c4XCLQFn1KMMu5cTanfcCh++6naStqHeRZDlY/mGC5l6yOH12r0g4dEQWHEkCKjvgXVnFmcqV+LncoEqa2znKGRGHd374=&authSecret=00000195dd2e96a30d5a0a3b19421a19').then(buffer => {
  //     let source = audioCtx.createBufferSource()
  //     source.buffer = buffer
  //     source.connect(audioCtx.destination)
  //     source.start()
  //   }).catch(() => {
  //     console.log('fail')
  //   })
  // },
  // loadAudio(url){
  //   return new Promise((resolve) => {
  //     wx.request({
  //       url,
  //       responseType: 'arraybuffer',
  //       success: res => {
  //         console.log('res.data', res.data)
  //         audioCtx.decodeAudioData(res.data, buffer => {
  //           resolve(buffer)
  //         }, err => {
  //           console.error('decodeAudioData fail', err)
  //           reject()
  //         })
  //       },
  //       fail: res => {
  //         console.error('request fail', res)
  //         reject()
  //       }
  //     })
  //   })
  // },
  showMsg(){
    console.log("你好啊!");
    wx.vibrateLong();
  },
  custom(){
    wx.openCustomerServiceChat({
      corpId: 'corpId',
      extInfo: {
        url: 'url',
      },
    })
  },
  jumpTo(){
    wx.navigateTo({
      url: '/secondary_page/venue_details/venue_details',
    })
  }
})
